/**
 * 地址管理路由模块
 */

const express = require('express');
const addressController = require('../controllers/addressController');
const { authenticateToken } = require('../middlewares/authMiddleware');
const { checkPermission } = require('../middlewares/permissionMiddleware');
const router = express.Router();

// 所有地址路由都需要认证Token
router.use(authenticateToken);

// 获取全部地址列表
router.get('/', addressController.getAddressList);

// 获取默认地址 - 放在动态路由之前
router.get('/default/get', addressController.getDefaultAddress);

// 获取省份列表 - 无需权限检查，仅需认证
router.get('/provinces', addressController.getProvinceList);

// 获取城市列表 - 无需权限检查，仅需认证
router.get('/citys/:provinceId', addressController.getCityList);

// 获取区县列表 - 无需权限检查，仅需认证
router.get('/districts/:cityId', addressController.getDistrictList);

// 通过ID字符串获取嵌套地址数据 - 无需权限检查，仅需认证
router.get('/nested', addressController.getNestedAddressByIdString);

// // 获取地址详情 - 放在最后
// router.get('/info/:id', checkPermission('address:info'), addressController.getAddress);

// // 创建地址
// router.post('/', checkPermission('address:create'), addressController.createAddress);

// // 更新地址
// router.put('/:id', checkPermission('address:update'), addressController.updateAddress);

// // 设置默认地址
// router.put('/:id/default', checkPermission('address:setDefault'), addressController.setDefaultAddress);

// // 删除单个地址
// router.delete('/:id', checkPermission('address:delete'), addressController.deleteAddress);

// // 批量删除地址
// router.delete('/batch/delete', checkPermission('address:batchDelete'), addressController.deleteBatchAddresses);

module.exports = router;